/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.MessageManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ 
/*    */ public class AddWhiteBoard extends AbstractAction
/*    */ {
/*    */   public AddWhiteBoard(AbstractHttpServlet servlet)
/*    */   {
/* 23 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 29 */     String title = Util.getURLParameter(request.getParameter("title"));
/* 30 */     String message = Util.getURLParameter(request.getParameter("message"));
/* 31 */     int visible = Util.getURLIntParameter(request.getParameter("visible"));
/* 32 */     String attachFiles = Util.getURLParameter(request
/* 33 */       .getParameter("attachFiles"));
/* 34 */     String permissionsId = "";
/* 35 */     MessageManager manager = new MessageManager();
/* 36 */     User u = super.getLoginUser(request);
/*    */ 
/* 38 */     int messageId = manager.add(title, message, 0, 
/* 39 */       attachFiles, visible, permissionsId, u.userId, u.companyId);
/*    */ 
/* 41 */     if (messageId == 0)
/*    */     {
/* 43 */       response.sendRedirect(request.getContextPath() + "/whiteboard/new");
/* 44 */       return;
/*    */     }
/*    */ 
/* 49 */     CompanyInfo companyInfo = super.getCompany(request);
/* 50 */     List params = new ArrayList();
/* 51 */     for (User user : companyInfo.users) {
/* 52 */       Object[] o = new Object[3];
/* 53 */       o[0] = Integer.valueOf(messageId);
/* 54 */       o[1] = user.userId;
/* 55 */       o[2] = Integer.valueOf(user.companyId);
/* 56 */       params.add(o);
/*    */     }
/* 58 */     manager.addRelation((Object[][])params.toArray(new Object[0][]));
/*    */ 
/* 60 */     response.sendRedirect(request.getContextPath() + "/whiteboard/" + 
/* 61 */       messageId);
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.AddWhiteBoard
 * JD-Core Version:    0.6.1
 */